package day11;

import com.mysql.jdbc.Connection;

import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class DDLTest3 {
    public static void main(String[] args) throws SQLException {

        /**
         * 贾链欲其事
         * 贾: 加载驱动
         * 链: 获得链接
         * 欲: 获得Statement语句对象
         * 执: 执行sql
         * 事: 释放
         */

        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        Connection conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/g2148?useSSL=false&useUnicode=true&characterEncoding=utf-8", "root", "123456");
        System.out.println("conn:" + conn);

        //获得语句对象
        Statement st = conn.createStatement();

        //执行语句对象
        String sql = "create table student(S_NO int(8) primary key auto_increment, S_NAME varchar(10), S_SEX varchar(2),S_SCORE DOUBLE, S_ADDF DOUBLE)";
        st.executeUpdate(sql);

        System.out.println("创建成功");

        conn.close();
    }
}
